FROM registry.docker.yit.com/base/java:openjdk-8-jre-alpine

MAINTAINER yitops

COPY zookeeper-3.4.8.tar.gz /

WORKDIR /

RUN apk add --no-cache bash \
    && mkdir /opt \
    && tar zxvf zookeeper-3.4.8.tar.gz \
    && rm -f zookeeper-3.4.8.tar.gz \
	&& mv /zookeeper-3.4.8 /opt/zookeeper \
	&& mkdir -p /tmp/zookeeper \
	&& mkdir -p /opt/zookeeper/data \
	&& mkdir -p /opt/zookeeper/zookeeper-log 

COPY zoo.cfg /opt/zookeeper/conf/zoo.cfg
COPY myid /opt/zookeeper/data
COPY zkEnv.sh /opt/zookeeper/bin/zkEnv.sh

RUN cd /opt/zookeeper/bin \
    && chmod +x ./zkEnv.sh

WORKDIR /opt/zookeeper

EXPOSE 2181 2888 3888

ENTRYPOINT ["/opt/zookeeper/bin/zkServer.sh"]
CMD ["start-foreground"]